
<jsp:include page="/header.jsp" />

		
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="com.ykwep.web.server.PMF"%>
<%@page import="com.ykwep.web.server.data.NewsItem"%>
<%@page import="java.util.List"%>		
		
		<h2>Add a News Item</h2>
			<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
	<script src="/ckeditor/_samples/sample.js" type="text/javascript"></script>
	<form action="/admin/add_news_item" method="post">
	  <div>Title:<br/> <input name="title"></input></div>
      
      <div>Publish:<br/> <input name="published" type="checkbox" checked></input></div>
    
      
      <div>Content:<br/> <textarea cols="75" id="editor1" name="content" rows="20"></textarea></div>
      		<script type="text/javascript">
				//<![CDATA[

					// This call can be placed at any point after the
					// <textarea>, or inside a <head><script> in a
					// window.onload event handler.

					// Replace the <textarea id="editor"> with an CKEditor
					// instance, using default configurations.
					CKEDITOR.replace( 'editor1' );

				//]]>
				</script>
      <div><input type="submit" value="Post" /></div>
    </form>
		
		<h2>News Items</h2>
		<%

    List<NewsItem> newsItems = NewsItem.getAllNewsItems();
    if (newsItems.isEmpty()) {
%>

<p>There are no news.</p>
<%
    } else {
        for (NewsItem g : newsItems) {
%>
		<%=g.getTitle() %> <%= g.getDate() %> <a href="/admin/edit_news_item.jsp?news_item_id=<%= g.getId() %>">Edit news</a> | <a href="/admin/delete_news_item?news_item_id=<%= g.getId() %>&delete=true">Delete news</a><br/>     
		<%    }
    }

%>
		

				
<jsp:include page="/footer.jsp" />
				